<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/5/23
 * Time: 11:11
 */
namespace kkw\admin\response;
use kkw\admin\table\GoodsTypeTable;
use kkw\user\Util;
use suda\core\Request;
use suda\core\Response;

class updateType extends  Response
{
    public function onRequest(Request $request)
    {
        Util::printHeader();
        $json = Request::json();
        $id= $json['id']; // 分类id
        $name= $json['name']; // 分类名
        $describe = $json['describe']; // 分类描述
        $goodsType = new GoodsTypeTable();
        try {
            $goodsType->update(['name'=>$name,'describe'=>$describe],['id'=>$id]);
        } catch (\suda\exception\SQLException $e) {
            $this->json(['code'=>$e->getCode(),'message'=> '更新数据成功']);
        }
        $this->json(['code'=>0,'message'=>'更新数据成功']);
    }
}